<template>
  <el-dialog v-model="chartVisible" title="光照曲线可视化" width="80%">
    <div ref="chartDom" style="width: 100%; height: 500px;"></div>
    </el-dialog>
  <div class="electricity-container">
     <div class="form-section">
      <h3 class="title">电需求</h3>

      <div class="input-group">
        <label class="input-label">电力需求</label>
        <div class="input-controls">
          <el-button plain @click="Electricity_demand1 = true" class="distribution-btn">  修改 </el-button>
            <el-dialog v-model="Electricity_demand1" title="change" width="500">
              <el-form :model="form">
              <el-form-item
                v-for="i in 24"
                :key="i"
                :label="i.toString()"
                :label-width="formLabelWidth"
              >
                <el-input v-model="form[`name${i}`]" autocomplete="off" />
              </el-form-item>
            </el-form>
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="Electricity_demand1 = false">Cancel</el-button>
                  <el-button type="primary" @click="submitData1 ">提交</el-button>
                </div>
              </template>n
            </el-dialog>

          <button @click="showChart1" class="distribution-btn">
            <span class="btn-text">可视化</span>
          </button>
            <button @click="selectFile1" class="distribution-btn">
                <span class="btn-text"  >加载数据</span>
                <input
                  type="file"
                  ref="fileInput1"
                  @change="onFileChange1"
                  entityType="DianXQ"
                  style="display: none;"
                />
                <span class="file-name">solar_spring.txt</span>
            </button>(1-24)
        </div>
      </div>
    <el-dialog v-model="dialogVisible" title="文件内容" width="80%">
      <pre>{{ fileContent }}</pre>
    </el-dialog>


      <div class="input-group">
        <label class="input-label">电转热需求</label>
        <div class="input-controls">
          <el-button plain @click="Electricity_demand2 = true" class="distribution-btn">修改</el-button>

          <el-dialog v-model="Electricity_demand2" title="change" width="500">
            <el-form :model="form">
              <el-form-item
                v-for="i in 24"
                :key="i"
                :label="i.toString()"
                :label-width="formLabelWidth"
              >
                <el-input v-model="form[`name${i + 24}`]" autocomplete="off" />
                <!-- i + 23 确保从 name24 开始 -->
              </el-form-item>
            </el-form>

            <template #footer>
              <div class="dialog-footer">
                <el-button @click="Electricity_demand2 = false">Cancel</el-button>
                <el-button type="primary" @click="submitData2">提交</el-button>
              </div>
            </template>
          </el-dialog>

          <button @click="showChart2" class="distribution-btn">
            <span class="btn-text">可视化</span>
          </button>
            <button @click="selectFile2" class="distribution-btn">
                <span class="btn-text"  >加载数据</span>
                <input
                  type="file"
                  ref="fileInput2"
                  @change="onFileChange2"
                  entityType="DianXQ"
                  style="display: none;"
                />
                <span class="file-name">solar_spring.txt</span>
            </button>(25-48)
        </div>
      </div>

      <div class="input-group">
        <label class="input-label">电转生物质能需求</label>
        <div class="input-controls">
          <el-button plain @click="Electricity_demand3 = true" class="distribution-btn">修改</el-button>
          <el-dialog v-model="Electricity_demand3" title="change" width="500">
            <el-form :model="form">
              <el-form-item
                v-for="i in 24"
                :key="i"
                :label="i.toString()"
                :label-width="formLabelWidth"
              >
                <el-input v-model="form[`name${i + 48}`]" autocomplete="off" />
              </el-form-item>
            </el-form>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="Electricity_demand3 = false">Cancel</el-button>
                <el-button type="primary" @click="submitData3">提交</el-button>
              </div>
            </template>
          </el-dialog>

          <button @click="showChart3" class="distribution-btn">
            <span class="btn-text">可视化</span>
          </button>
            <button @click="selectFile3" class="distribution-btn">
                <span class="btn-text"  >加载数据</span>
                <input
                  type="file"
                  ref="fileInput3"
                  @change="onFileChange3"
                  entityType="DianXQ"
                  style="display: none;"
                />
                <span class="file-name">solar_spring.txt</span>
            </button>(49-72)
        </div>
      </div>

      <!-- 替换后的 冬季光照曲线 -->
      <div class="input-group">
        <label class="input-label">用于交通的电能需求</label>
        <div class="input-controls">
          <el-button plain @click="Electricity_demand4 = true" class="distribution-btn">修改</el-button>
          <el-dialog v-model="Electricity_demand4" title="change" width="500">
            <el-form :model="form">
              <el-form-item
                v-for="i in 24"
                :key="i"
                :label="i.toString()"
                :label-width="formLabelWidth"
              >
                <el-input v-model="form[`name${i + 72}`]" autocomplete="off" />
              </el-form-item>
            </el-form>
            <template #footer>
              <div class="dialog-footer">
                <el-button @click="Electricity_demand4 = false">Cancel</el-button>
                <el-button type="primary" @click="submitData4">提交</el-button>
              </div>
            </template>
          </el-dialog>

          <button @click="showChart4" class="distribution-btn">
            <span class="btn-text">可视化</span>
          </button>
            <button @click="selectFile4" class="distribution-btn">
                <span class="btn-text"  >加载数据</span>
                <input
                  type="file"
                  ref="fileInput4"
                  @change="onFileChange4"
                  entityType="DianXQ"
                  style="display: none;"
                />
                <span class="file-name">solar_spring.txt</span>
            </button>(73-96)
        </div>
      </div>
  </div>


    <div class="info-section">
      <h3 class="title">需求响应数据</h3>

      <div class="info-grid">
        <div class="info-card">
          <label class="info-label">需求响应(一天)</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand1" class="form-input small">
            <span class="info-value">MWh</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">需求响应(一天)最大负荷</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand2" class="form-input small">
            <span class="info-value">MW</span>
          </div>
        </div>

        <div class="info-card highlight">
          <label class="info-label">需求响应(一周)</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand3" class="form-input small">
            <span class="info-value">MWh</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">需求响应(一周)最大负荷</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand4" class="form-input small">
            <span class="info-value">MW</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">需求响应(四周)</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand5" class="form-input small">
            <span class="info-value">MWh</span>
          </div>
        </div>

        <div class="info-card">
          <label class="info-label">需求响应(四周)最大负荷</label>
          <div class="info-content">
            <input type="number" v-model="Flexible_demand6" class="form-input small">
            <span class="info-value">MW</span>
          </div>
        </div>
        <button class="distribution-btn emission-submit-btn" @click="submit">
          <span class="btn-text">提交</span>

        </button>
      </div>
    </div>

    <div class="price-section">
      <h3 class="title">电价设置</h3>
      <div class="input-group">
        <label class="input-label">电价</label>
        <div class="input-controls">
          <el-button plain @click="Price = true" class="distribution-btn">  修改 </el-button>
            <el-dialog v-model="Price" title="change" width="500">
              <el-form :model="form">
              <el-form-item
                v-for="i in 24"
                :key="i"
                :label="i.toString()"
                :label-width="formLabelWidth"
              >
                <el-input v-model="form[`price${i + 24}`]" autocomplete="off" />
              </el-form-item>
            </el-form>
              <template #footer>
                <div class="dialog-footer">
                  <el-button @click="Price = false">Cancel</el-button>
                  <el-button type="primary" @click="submitData5">提交</el-button>
                </div>
              </template>
            </el-dialog>

          <button @click="showChart5" class="distribution-btn">
            <span class="btn-text">可视化</span>
          </button>
            <button @click="selectFile5" class="distribution-btn">
                <span class="btn-text"  >加载数据</span>
                <input
                  type="file"
                  ref="fileInput5"
                  @change="onFileChange5"
                  entityType="ShiChang"
                  style="display: none;"
                />
                <span class="file-name">solar_spring.txt</span>
            </button>(25-48)
        </div>
      </div>
    <el-dialog v-model="dialogVisible" title="文件内容" width="80%">
      <pre>{{ fileContent }}</pre>
    </el-dialog>
    </div>
  </div>
</template>



<script lang="ts" setup>
import { reactive, ref, onMounted } from 'vue'
import axios from 'axios'
import { ElMessage ,ElButton,ElMessageBox } from 'element-plus'
import * as echarts from 'echarts'

const selectFile1 = () => {
  fileInput1.value!.click()
}

const selectFile2 = () => {
  fileInput2.value!.click()
}

const selectFile3 = () => {
  fileInput3.value!.click()
}

const selectFile4 = () => {
  fileInput4.value!.click()
}

const selectFile5 = () => {
  fileInput5.value!.click()
}
const onFileChange1 = () => handleCsvUpload(fileInput1, 1)     // 春季 ID 1–24
const onFileChange2 = () => handleCsvUpload(fileInput2, 25)    // 夏季 ID 25–48
const onFileChange3 = () => handleCsvUpload(fileInput3, 49)    // 秋季 ID 49–72
const onFileChange4 = () => handleCsvUpload(fileInput4, 73)    // 冬季 ID 73–96
const onFileChange5 = () => handleCsvUpload(fileInput5, 25)

const handleCsvUpload = async (
  fileInput: Ref<HTMLInputElement | null>,
  startId: number
) => {
  const file = fileInput.value?.files?.[0]
  if (!file) return

  const entityType = fileInput.value?.getAttribute('entityType') || ''
  if (!file.name.endsWith('.csv')) {
    ElMessageBox.alert('请选取 csv 文件！', '错误', {
      confirmButtonText: '确定',
      type: 'error',
      closeOnClickModal: false,
      callback: () => {
        if (fileInput.value) {
          fileInput.value.value = ''
        }
      }
    })
    return
  }

  const formData = new FormData()
  formData.append('file', file)

  let url = ''
  if (entityType === 'DianXQ') {
    url = `http://localhost:8080/dianxq/upload/${startId}`
  } else if (entityType === 'ShiChang') {
    url = `http://localhost:8080/shichang/upload/${startId}`
  } else {
    ElMessage.error('未知的数据类型，无法上传')
    return
  }

  try {
    const res = await axios.post(url, formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })

    ElMessageBox.alert(res.data.message || '上传成功', '成功', {
      confirmButtonText: '确定',
      type: 'success',
      closeOnClickModal: false,
      callback: () => {
        fileInput.value!.value = ''
      }
    })
  } catch (err: any) {
    const message = err.response?.data?.message || '上传失败'
    ElMessageBox.alert(message, '错误', {
      confirmButtonText: '确定',
      type: 'error',
      closeOnClickModal: false,
      callback: () => {
        fileInput.value!.value = ''
      }
    })
  }
}

const submit = async () => {
  try {
    const payloads = [
      { id: 1, value: parseFloat(Flexible_demand1.value) || 0 },
      { id: 2, value: parseFloat(Flexible_demand2.value) || 0 },
      { id: 3, value: parseFloat(Flexible_demand3.value) || 0 },
      { id: 4, value: parseFloat(Flexible_demand4.value) || 0 },
      { id: 5, value: parseFloat(Flexible_demand5.value) || 0 },
      { id: 6, value: parseFloat(Flexible_demand6.value) || 0 },

    ];

    for (const item of payloads) {
      await axios.put('http://localhost:8080/xiangying', item);
    }

    ElMessage.success('已成功更新到数据库');
  } catch (error) {
    console.error('提交失败:', error);
    ElMessage.error('提交失败，请检查数据格式或网络连接');
  }
};

const chartVisible = ref(false)
const chartDom = ref<HTMLDivElement | null>(null)

const fileInput1 =  ref<HTMLInputElement | null>(null)
const fileInput2 =  ref<HTMLInputElement | null>(null)
const fileInput3 =  ref<HTMLInputElement | null>(null)
const fileInput4 =  ref<HTMLInputElement | null>(null)
const fileInput5 =  ref<HTMLInputElement | null>(null)



const Electricity_demand1 = ref(false)
const Electricity_demand2 = ref(false)
const Electricity_demand3 = ref(false)
const Electricity_demand4 = ref(false)

const Price = ref(false)

const formLabelWidth = '140px'
interface DataItem {
  value: string | number;
}
const processDian1xqData = (data: DataItem[]) => {
  const seasons = ['电需求']
  const result: Record<string, number[]> = {}

  seasons.forEach((season, idx) => {
    result[season] = data
      .slice(idx * 24, (idx + 1) * 24)
      .map(item => parseFloat(String(item.value)))
  })

  return result
}

// 显示图表函数
const showChart1 = async () => {
  try {
    // 获取所有数据
    const response = await axios.get('http://localhost:8080/dianxq/all')
    const data = response.data

    // 处理数据
    const chartData = processDian1xqData(data)

    // 显示图表
    chartVisible.value = true
    setTimeout(() => {  // 延迟确保DOM渲染
      const myChart = echarts.init(chartDom.value!)

      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['电需求']
        },
        xAxis: {
          type: 'category',
          data: Array.from({ length: 24 }, (_, i) => `${i}:00`)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '电需求',
            type: 'line',
            data: chartData['电需求'],
            smooth: true
          },
        ]
      }

      myChart.setOption(option)
    }, 100)
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}


const processDian2xqData = (data: DataItem[]) => {
  const result: Record<string, number[]> = {}
  result['电转热需求'] = data.slice(24, 48).map(item => parseFloat(String(item.value)))
  return result
}

// 显示图表函数
const showChart2 = async () => {
  try {
    // 获取所有数据
    const response = await axios.get('http://localhost:8080/dianxq/all')
    const data = response.data

    // 处理数据
    const chartData = processDian2xqData(data)

    // 显示图表
    chartVisible.value = true
    setTimeout(() => {  // 延迟确保DOM渲染
      const myChart = echarts.init(chartDom.value!)

      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['电转热需求']
        },
        xAxis: {
          type: 'category',
          data: Array.from({ length: 24 }, (_, i) => `${i}:00`)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '电转热需求',
            type: 'line',
            data: chartData['电转热需求'],
            smooth: true
          },
        ]
      }

      myChart.setOption(option)
    }, 100)
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}



const processDian3xqData = (data: DataItem[]) => {
  const result: Record<string, number[]> = {}
  result['电转生物质能需求'] = data.slice(48, 72).map(item => parseFloat(String(item.value)))
  return result
}

// 显示图表函数
const showChart3 = async () => {
  try {
    // 获取所有数据
    const response = await axios.get('http://localhost:8080/dianxq/all')
    const data = response.data

    // 处理数据
    const chartData = processDian3xqData(data)

    // 显示图表
    chartVisible.value = true
    setTimeout(() => {  // 延迟确保DOM渲染
      const myChart = echarts.init(chartDom.value!)

      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['电转生物质能需求']
        },
        xAxis: {
          type: 'category',
          data: Array.from({ length: 24 }, (_, i) => `${i}:00`)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '电转生物质能需求',
            type: 'line',
            data: chartData['电转生物质能需求'],
            smooth: true
          },
        ]
      }

      myChart.setOption(option)
    }, 100)
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}

const processDian4xqData = (data: DataItem[]) => {
  const result: Record<string, number[]> = {}
  result['交通电能需求'] = data.slice(72, 96).map(item => parseFloat(String(item.value)))
  return result
}

// 显示图表函数
const showChart4 = async () => {
  try {
    // 获取所有数据
    const response = await axios.get('http://localhost:8080/dianxq/all')
    const data = response.data

    // 处理数据
    const chartData = processDian4xqData(data)

    // 显示图表
    chartVisible.value = true
    setTimeout(() => {  // 延迟确保DOM渲染
      const myChart = echarts.init(chartDom.value!)

      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['交通电能需求']
        },
        xAxis: {
          type: 'category',
          data: Array.from({ length: 24 }, (_, i) => `${i}:00`)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '交通电能需求',
            type: 'line',
            data: chartData['交通电能需求'],
            smooth: true
          },
        ]
      }

      myChart.setOption(option)
    }, 100)
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}


const processDianjiaData  = (data: DataItem[]) => {
  const result: Record<string, number[]> = {}
  result['电价'] = data.slice(24, 48).map(item => parseFloat(String(item.value)))
  return result
}


const showChart5 = async () => {
  try {
    // 获取所有数据
    const response = await axios.get('http://localhost:8080/shichang/all')
    const data = response.data

    // 处理数据
    const chartData = processDianjiaData(data)

    // 显示图表
    chartVisible.value = true
    setTimeout(() => {  // 延迟确保DOM渲染
      const myChart = echarts.init(chartDom.value!)

      const option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['电价']
        },
        xAxis: {
          type: 'category',
          data: Array.from({ length: 24 }, (_, i) => `${i}:00`)
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '电价',
            type: 'line',
            data: chartData['电价'],
            smooth: true
          },
        ]
      }

      myChart.setOption(option)
    }, 100)
  } catch (error) {
    console.error('获取数据失败:', error)
  }
}

type FormType = Record<`name${number}` | `price${number}`, string> & {
  region: string
  date1: string
  date2: string
  delivery: boolean
  type: string[]
  resource: string
  desc: string
}

const form = reactive<FormType>({
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
  ...Object.fromEntries(Array.from({ length: 96 }, (_, i) => [`name${i + 1}`, ''])),
  ...Object.fromEntries(Array.from({ length: 24 }, (_, i) => [`price${i + 1}`, '']))
})

const Flexible_demand1 = ref('0')
const Flexible_demand2 = ref('0')
const Flexible_demand3 = ref('0')
const Flexible_demand4 = ref('0')
const Flexible_demand5 = ref('0')
const Flexible_demand6 = ref('0')


const dialogVisible = ref(false)
const fileContent = ref('')


onMounted(async () => {
  try {
    const solarPromises: Promise<{ data: { value: string | number } }>[] = []
    for (let i = 1; i <= 96; i++) {
      solarPromises.push(axios.get(`http://localhost:8080/dianxq/${i}`))
    }
    const solarResponses = await Promise.all(solarPromises)
    const solarDataList = solarResponses.map(res => res.data)
    for (let i = 1; i <= 96; i++) {
      form[`name${i}`] = solarDataList[i - 1].value.toString()
    }


    const pricePromises: Promise<{ data: { value: string | number } }>[] = []
    for (let i = 1; i <= 48; i++) {
      pricePromises.push(axios.get(`http://localhost:8080/shichang/${i}`))
    }
    const priceResponses = await Promise.all(pricePromises)
    const priceDataList = priceResponses.map(res => res.data)
    for (let i = 1; i <= 48; i++) {
      form[`price${i}`] = priceDataList[i - 1].value.toString()
    }

    const response111 = await axios.get('http://localhost:8080/xiangying/1')
    const response222 = await axios.get('http://localhost:8080/xiangying/2')
    const response333 = await axios.get('http://localhost:8080/xiangying/3')
    const response444 = await axios.get('http://localhost:8080/xiangying/4')
    const response555 = await axios.get('http://localhost:8080/xiangying/5')
    const response666 = await axios.get('http://localhost:8080/xiangying/6')
    const data111 = response111.data
    const data222 = response222.data
    const data333 = response333.data
    const data444 = response444.data
    const data555 = response555.data
    const data666 = response666.data
    Flexible_demand1.value = data111.value
    Flexible_demand2.value = data222.value
    Flexible_demand3.value = data333.value
    Flexible_demand4.value = data444.value
    Flexible_demand5.value = data555.value
    Flexible_demand6.value = data666.value

  } catch (error: unknown) {
    let errorMessage = '获取数据失败'

    if (axios.isAxiosError(error)) {
      errorMessage += `（状态码：${error.response?.status}）`
      if (error.response?.data) {
        errorMessage += `\n详细信息：${error.response.data.message || '无'}`
      }
    } else if (error instanceof Error) {
      errorMessage += `\n${error.message}`
    } else {
      errorMessage += '\n未知错误类型'
    }

    ElMessage.error({
      message: errorMessage,
      duration: 5000,
      showClose: true,
    })
  }
})


const submitData1 = async () => {
  try {
    for (let i = 1; i <= 24; i++) {
      const newValue = parseFloat(form[`name${i}`]) || 0;
      await axios.put(`http://localhost:8080/dianxq/single/${i}`, { value: newValue });
    }
    ElMessage.success('电力需求数据更新成功');
    Electricity_demand1.value = false;
  } catch (error) {
    ElMessage.error('更新失败，请检查输入格式');
    console.error('更新异常:', error);
  }
};
const submitData2 = async () => {
  try {
    for (let i = 25; i <= 48; i++) {
      const newValue = parseFloat(form[`name${i}`]) || 0;
      await axios.put(`http://localhost:8080/dianxq/single/${i}`, { value: newValue });
    }
    ElMessage.success('电转热需求数据更新成功');
    Electricity_demand2.value = false;
  } catch (error) {
    ElMessage.error('更新失败，请检查输入格式');
    console.error('更新异常:', error);
  }
};
const submitData3 = async () => {
  try {
    for (let i = 49; i <= 72; i++) {
      const newValue = parseFloat(form[`name${i}`]) || 0;
      await axios.put(`http://localhost:8080/dianxq/single/${i}`, { value: newValue });
    }
    ElMessage.success('电转生物质能数据更新成功');
    Electricity_demand3.value = false;
  } catch (error) {
    ElMessage.error('更新失败，请检查输入格式');
    console.error('更新异常:', error);
  }
};
const submitData4 = async () => {
  try {
    for (let i = 73; i <= 96; i++) {
      const newValue = parseFloat(form[`name${i}`]) || 0;
      await axios.put(`http://localhost:8080/dianxq/single/${i}`, { value: newValue });
    }
    ElMessage.success('用于交通的电能数据更新成功');
    Electricity_demand4.value = false;
  } catch (error) {
    ElMessage.error('更新失败，请检查输入格式');
    console.error('更新异常:', error);
  }
};
const submitData5 = async () => {
  try {
    for (let i = 25; i <= 48; i++) {
      const newValue = parseFloat(form[`price${i}`]) || 0;
      await axios.put(`http://localhost:8080/shichang/single/${i}`, { value: newValue });
    }
    ElMessage.success('电转热需求数据更新成功');
    Price.value = false;
  } catch (error) {
    ElMessage.error('更新失败，请检查输入格式');
    console.error('更新异常:', error);
  }
};

</script>

<style scoped>
.electricity-container {
  background-color: #f8fafc;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  padding: 12px;
  max-width: 1000px;
  margin: 0 auto;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #1e293b;
}

.title {
  color: #4c1d95;
  text-align: center;
  margin-bottom: 32px;
  font-size: 28px;
  font-weight: 700;
  padding-bottom: 16px;
  border-bottom: 2px solid #7c3aed;
  letter-spacing: 0.5px;
}

.section-title {
  color: #475569;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.form-section, .info-section, .price-section {
  background-color: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.input-group {
  display: flex;
  margin-bottom: 18px;
  gap: 16px;
}

.input-label {
  min-width: 180px;
  font-weight: 500;
  color: #475569;
  padding-top: 10px;
}

.input-controls {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-wrapper {
  display: flex;
  align-items: center;
  /* background-color: #f8fafc; */
  border-radius: 8px;
  padding: 2px;
  border: 1px solid #f8fafc;
}

.form-input {
  padding: 10px 16px;
  border: 1px solid #053676;
  border-radius: 6px;
  width: 80px;
  text-align: right;
  font-size: 15px;
  background: transparent;
  color: #1e293b;
}

.form-input.small {
  width: 100px;

}

.form-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

.unit {
  margin: 0 8px;
  color: #64748b;
  font-size: 10px;
  font-weight: 500;
}

.distribution-btn {
  background-color: #7c3aed;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.distribution-btn:hover {
  background-color: #6d28d9;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.btn-text {
  font-size: 14px;
  line-height: 1.2;
}

.file-name {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-style: italic;
  margin-top: 2px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.info-card {
  background-color: #f8fafc;
  padding: 18px;
  border-radius: 10px;
  border-left: 4px solid #7c3aed;
  transition: transform 0.2s, box-shadow 0.2s;
}

.info-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.info-label {
  display: block;
  font-weight: 500;
  color: #475569;
  margin-bottom: 10px;
  font-size: 15px;
}

.info-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-value {
  font-weight: 600;
  color: #4c1d95;
  font-size: 15px;
  white-space: nowrap;
}

.price-input-group {
  display: flex;
  align-items: center;
  gap: 16px;
}

.price-label {
  font-weight: 500;
  color: #475569;
  min-width: 180px;
}

.price-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

@media (max-width: 768px) {
  .electricity-container {
    padding: 24px;
    border-radius: 0;
  }

  .input-group {
    flex-direction: column;
    gap: 8px;
  }

  .input-label {
    min-width: auto;
    padding-top: 0;
    margin-bottom: 6px;
  }

  .input-controls {
    width: 100%;
  }

  .form-input {
    width: 100%;

  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .price-input-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
</style>
